#ifndef __CM_NAT_ICE_LINK_POOL_H__
#define __CM_NAT_ICE_LINK_POOL_H__

#include "IceLink.h"

namespace cm_nat
{
    class IceLinkPool
    {
    public:
        IceLinkPool();
        ~IceLinkPool();

        int setHostIP( IPAddress host_ip );
        int setup(UInt16 poolSize, SocketAddress stunAddress);
        int teardown();
        
        IceLink* allocateLink();
        int releaseLink( IceLink* p_link );
        int startCheckConnection( IceLink* link, SocketAddress peer );

        //callback for IceLink to  report check result
        void onCheckResult( IceLink* link, int result );

    protected:
        ByteBufferPool m_bufferPool;
        SocketReactor  m_reactor;
        Thread m_reactorThread;
        BaseTimer m_timer;

        IceLinkList m_readyLinks;
        IceLinkList m_links;

        SocketAddress m_stunAddress;
        IPAddress m_hostIP;
    };
}

#endif